/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 *
 * @author MRDO
 */
public class ImageProcess extends JFrame{
    public ImageIcon scaleImage(String src, double scale){
        ImageIcon icon = new ImageIcon(getClass().getResource(src));
        int w = (int)(scale*icon.getImage().getWidth(this));
        int h = (int) (scale*icon.getImage().getHeight(this));
        return new ImageIcon(icon.getImage().getScaledInstance(w, h, w));
    }
    
    public void centerPosition(JFrame frame,int x,int y) {
        frame.setSize(x,y);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int width = screenSize.width;
        int height = screenSize.height;
        frame.setLocation((width - x) / 2, (height - y) / 2);
    }
    
    public void centerPosition(JDialog frame,int x,int y) {
        frame.setSize(x,y);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int width = screenSize.width;
        int height = screenSize.height;
        frame.setLocation((width - x) / 2, (height - y) / 2);
    }
}
